package com.zw.cc.stock.service.policy.cci;

import com.zw.cc.stock.common.PolicyTypeEnum;
import com.zw.cc.stock.model.QuotesPo;
import com.zw.cc.stock.service.policy.CalculateService;
import com.zw.cc.stock.util.calculateutil;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * CCI 卖出信号
 * Created by zhaowuz on 2018/1/11
 */
@Service
public class CCISellSignal implements CalculateService<List<QuotesPo>>{

    private float offset = 1.1f; //值越大 CCI下跌角度越大

    private int highest = 120;

    @Override
    public boolean calculate(List<QuotesPo> quotesPos) {
        List<Integer> cci = calculateutil.calcCCICalculate(quotesPos);
        Collections.reverse(cci);
        return cci.get(0) > highest && cci.get(1) / cci.get(0) > offset;
    }

    @Override
    public PolicyTypeEnum getType() {
        return PolicyTypeEnum.CCI_SELL;
    }
}
